<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<html>
<head>
	<meta name="decorator" content="moduleView" />
	<link href="${staticPath}/lib/datetimepicker/0.0.11/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css">
	<link href="${staticPath}/lib/chosen/1.1.0/chosen.min.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" language="javascrīpt">
		$(document).ready(function (){
			$(".chosen-select").chosen({});
			//货币格式化
			$('[data-accounting]').each(function (){
				var $this = $(this);
				if($this.attr("data-accounting-precision") && ""!=$this.attr("data-accounting-precision")){
					$this.html(accounting.formatMoney($this.attr("data-accounting"),"¥ ",$this.attr("data-accounting-precision")*1));
				}else{
					$this.html(accounting.formatMoney($this.attr("data-accounting"),"¥ "));
				}
			});
			;
		});
			function printme(){
				document.body.innerHTML=document.getElementById('span').innerHTML+'<br/>'+document.getElementById('home').innerHTML;
				window.print();
			}
			function getUrl(url){ 
			  $("#versionFrame").attr("src",url);
			}
			
			//确认账单
			function _confirm(){
				var item = confirm("是否已经核对完对账单!");
				if(item){
					$.ajax({
						type: "POST",
						url: "${contextPath}/biz/statement/statementSales/reconciliation",
						data:{ "id":$("#statementSalesId").val()},
						success: function(json) {
							var jsonObj =eval('(' + json + ')');
							if(jsonObj.success){
								alert("对账单确认成功!");
								$("#addException").hide();
								$("#reconciliation").hide();
								$("#unReconciliation").text("已对账");
								
							}else{
								alert("对账单确认失败!");
							}
						}
					});
					
				}
			}
</script>
</head>
<body>
	<input type="hidden" value="${statementSales.id}" id="statementSalesId">
	<div class="panel panel-default"> 
		  <div class="col-xs-12 panel-heading">
			  <span class="panel-title o-v-action pull-left" id="span">
			    	销售对账单详细信息  
		    </span>
			    <h3 class="panel-title o-v-action">
			    <a class="btn btn-default btn-sm pull-right" href="${contextPath}/biz/statement/statementSales/list">返回</a>
			    <c:if test="${statementSales.isReconciliation==0}">
			    <a class="btn btn-danger btn-sm pull-right"  role="button" id="addException" href="${contextPath}/biz/statement/statementSalesErro/add?id=${statementSales.id}">异常</a>
			    <a class="btn btn-success btn-sm pull-right" role="button"  onclick="_confirm()" id="reconciliation">确认</a></c:if>
			    <a class="btn btn-primary btn-sm pull-right" role="button"  onclick="printme()"target="_self">打印</a>
			    
			    </h3>
		  </div>
	  <div>
		   <ul class="nav nav-tabs" id="myTab">
		
			</ul> 
			<div class="tab-content">
			  <div class="tab-pane active" id="home">
			  <tags:message content="${message}"/>
			  <table class="table table-bordered">
			  		<tbody>
			  			<tr>
					  		<td class="text-left" style="width: 20%"><strong>销售日期:</strong></td>
					  		<td><fmt:formatDate value="${statementSales.saleDate}" pattern="yyyy-MM-dd"/></td>
					  		<td class="text-left" style="width: 20%"><strong>对账状态:</strong></td>
					  		<td><ossp:value dictType="RECONCILIATION_TYPE" key="${statementSales.isReconciliation}"></ossp:value></td>
					  		<td class="text-left" style="width: 20%"><strong>供应商编号:</strong></td>
					  		<td>${statementSales.supplierNo}</td>
					  	</tr>
					  	<tr>
					  		
					  		<td class="text-left" style="width: 20%"><strong>销售额:</strong></td>
					  		
					  		<td data-accounting="${statementSales.sales}"></td>
					  		<td class="text-left" style="width: 20%"><strong>信用卡金额:</strong></td>
					  		<td data-accounting="${statementSales.prepaidCardAmount}" ></td>
					  		<td class="text-left" style="width: 20%"><strong>储值卡金额:</strong></td>
					  		<td data-accounting="${statementSales.creditCardAmount}"></td>
					  	</tr>
			  		</tbody>		  		
			  </table>
					<div class="panel-heading panel-default">
				    <h2 class="panel-title o-v-action">
				    	销售单列表
				    </h2>
				  </div>
				  <table class="table table-striped table-hover o-l-table" id="table1">
						<thead>
							<tr>
											
											<th>销售日期</th>
											<th>销售单号</th>
											<th>收银员</th>
											<th>收银金额</th>
										</tr>
						</thead>
						<tbody>
							<c:forEach items="${list}" var="statementSaleNote">
											<tr data-herf="${contextPath}/biz/statement/statementSaleDetail/list?billNo=${statementSaleNote.billNo}" data-target="_self">
												<td><fmt:formatDate value="${statementSaleNote.saleDate}" pattern="yyyy-MM-dd"/></td>
												<td>${statementSaleNote.billNo}</td>
												<td>${statementSaleNote.cashier}</td>
												<td data-accounting="${statementSaleNote.amount}"></td>								
											</tr>
										</c:forEach>
						</tbody>
				</table>
				 </div>
				 
			</div> 
		</div> 
	</div>
	<script type="text/javascript" src="${staticPath}/js/list.js"></script>	
	<script src="${staticPath}/lib/datetimepicker/0.0.11/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
	<script src="${staticPath}/lib/datetimepicker/0.0.11/js/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
	<script src="${staticPath}/lib/chosen/1.1.0/chosen.jquery.js" type="text/javascript"></script>
	<script src="${staticPath}/js/ossp-jquery-chosen.js" type="text/javascript"></script>
	<script src="${staticPath}/lib/accounting/0.3.2/accounting.min.js" type="text/javascript"></script>
</body>
</html>